import re
from playwright.sync_api import Playwright, sync_playwright, expect


def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()
    page = context.new_page()
    page.goto("https://emsp-test.eiceducation.com.cn/admin/login")
    page.get_by_role("textbox", name="").click()
    page.get_by_role("textbox", name="").fill("mumulin")
    page.get_by_role("textbox", name="").press("Tab")
    page.get_by_role("textbox", name="").click()
    page.get_by_role("textbox", name="").fill("h1058386570")
    page.get_by_role("button", name="登 录").click()
    page.get_by_role("link", name=" 全方位测评 ").click()
    page.get_by_role("link", name="账号管理").click()
    page.get_by_role("button", name="添加").click()
    page.get_by_role("textbox", name="请输入账号", exact=True).click()
    page.get_by_role("textbox", name="请输入账号", exact=True).fill("mm2")
    page.get_by_role("textbox", name="请输入账号", exact=True).press("Tab")
    page.get_by_role("textbox", name="请输入密码").fill("a123456")
    page.get_by_role("textbox", name="请输入密码").press("Tab")
    page.get_by_role("textbox", name="请输入描述").fill("自动测试")
    page.get_by_role("button", name="确定").click()
    page.get_by_text("何兴林").first.click()
    page.get_by_text("退出登录").click()

    # ---------------------
    context.close()
    browser.close()


with sync_playwright() as playwright:
    run(playwright)
